package com.lan.enums;

import java.util.stream.Stream;

public enum  UserStatusEnum {

    USER_NO(0, "停用"),
    USER_YES(1, "启用");

    /**
     * 枚举值编码.
     **/
    private final Integer value;
    /**
     * 枚举值中文名称.
     **/
    private final String name;

    UserStatusEnum(final Integer value, final String name) {
        this.value = value;
        this.name = name;
    }

    public Integer getValue() {
        return value;
    }

    public String getName() {
        return name;
    }


    public static String getNameByValue(final Integer value) {
        return Stream.of(UserStatusEnum.values())
                .filter(x -> x.getValue() == value.intValue())
                .findFirst()
                .map(UserStatusEnum::getName)
                .orElse(null);
    }

}
